package com.cmii.sjw.department.control.jsc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cmii.sjw.department.control.jsc.mapper.UniversityBasicInfoMapper;
import com.cmii.sjw.department.control.jsc.mapper.UniversityIndicatorsMapper;
import com.cmii.sjw.department.control.jsc.model.UniversityBasicInfo;
import com.cmii.sjw.department.control.jsc.model.UniversityIndicators;
import com.cmii.sjw.department.control.jsc.service.UniversityBasicInfoService;
import com.cmii.sjw.department.control.jsc.service.UniversityIndicatorsService;
import com.cmii.sjw.department.control.jsc.vo.UniversityBasicInfoVO;
import com.cmii.sjw.department.control.jsc.vo.UniversityIndicatorsVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


@Slf4j
@Service("UniversityBasicInfoService")
public class UniversityBasicInfoServiceImpl extends ServiceImpl<UniversityBasicInfoMapper, UniversityBasicInfo> implements UniversityBasicInfoService {
    @Autowired
    private UniversityBasicInfoMapper universityBasicInfoMapper;

    @Override
    public List<UniversityBasicInfoVO> listGroupedByType(String universityName) {
        List<UniversityBasicInfo> list = this.lambdaQuery()
                .like(StringUtils.isNotBlank(universityName), UniversityBasicInfo::getUniversityName, universityName)
                .eq(UniversityBasicInfo::getIsDeleted, 0)
                .orderByAsc(UniversityBasicInfo::getType)
                .list();


        return list.stream().map(item -> {
            UniversityBasicInfoVO vo = new UniversityBasicInfoVO();
            BeanUtils.copyProperties(item, vo);
            return vo;
        }).collect(Collectors.toList());
    }
}
